home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Pane2 / c / AddPane < prev    next >
Text File  |  1995-08-23  |  4KB  |  124 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Pane2.AddPane.c
  12.     Author:  Copyright © 1995 Andrew Sellors.
  13.     Version: 1.04 (4th August 1995)
  14.     Purpose: Handles windows with panes.
  15. */
  16.  
  17. #include "DeskLib:Pane2.h"
  18. #include "Pane2Defs.h"
  19. #include "Desklib:Event.h"
  20. #include "DeskLib:Template.h"
  21. #include "Desklib:EventMsg.h"
  22. #include "Desklib:Error.h"
  23.  
  24. #include <stdlib.h>
  25.  
  26.  
  27. /******************************************************************************/
  28.  
  29. extern BOOL Pane2_AddPane(window_handle mainwindow, window_handle panewindow,
  30.                           wimp_point *paneoffset, wimp_point *panesize, int flags)
  31. {
  32.  /*
  33.   * Adds the pane window 'panewindow' to the main window 'mainwindow'.
  34.   * If 'paneoffset' is not NULL then this is taken as the offset between the
  35.   * pane and the main window instead of the positions in the template.
  36.   * If 'panesize' is not NULL then this is taken as the size of the pane
  37.   * instead of the size in the template.
  38.   */
  39.   main_listelement *mainelement;
  40.   pane_listelement *paneelement;
  41.   window_state mainstate;
  42.   window_state panestate;
  43.  
  44.  /*
  45.   * find element for main window and return FALSE if mainwindow not present
  46.   */
  47.   mainelement = FindMainWindow(mainwindow);
  48.   if(mainelement == NULL)
  49.      return(FALSE); /* not found */
  50.  
  51.  /*
  52.   * malloc memory for list element and return FALSE if fails
  53.   */
  54.   paneelement = malloc(sizeof(pane_listelement));
  55.   if(paneelement == NULL)
  56.      return(FALSE); /* failed */
  57.  
  58.  /*
  59.   * get info about main and pane windows
  60.   */
  61.   Wimp_GetWindowState(mainwindow, &mainstate);
  62.   Wimp_GetWindowState(panewindow, &panestate);
  63.  
  64.  /*
  65.   * initialise list header
  66.   */
  67.   LinkList_Init(&(paneelement->header));
  68.  
  69.  /*
  70.   * fill element
  71.   */
  72.   paneelement->panewindow = panewindow;
  73.   paneelement->mainwindow = mainwindow;
  74.   paneelement->paneflags.value = flags;
  75.  
  76.   if(paneoffset != NULL) /* if pane offset is provided */
  77.      paneelement->paneoffset = *paneoffset;
  78.  
  79.   else{ /* use template pane offset */
  80.  
  81.      paneelement->paneoffset.x = panestate.openblock.screenrect.min.x -
  82.                                  mainstate.openblock.screenrect.min.x;
  83.  
  84.  
  85.      if(paneelement->paneflags.data.maintop) /* pane fixed to top of window */
  86.         paneelement->paneoffset.y = mainstate.openblock.screenrect.max.y;
  87.  
  88.      else /* pane fixed to bottom of window */
  89.         paneelement->paneoffset.y = mainstate.openblock.screenrect.min.y;
  90.  
  91.      if(paneelement->paneflags.data.panetop) /* pane fixed using top of pane */
  92.         paneelement->paneoffset.y -= panestate.openblock.screenrect.max.y;
  93.  
  94.      else /* pane fixed using bottom of pane */
  95.         paneelement->paneoffset.y -= panestate.openblock.screenrect.min.y;
  96.  
  97.   }
  98.  
  99.   if(panesize != NULL) /* if pane size is provided */
  100.      paneelement->panesize = *panesize;
  101.  
  102.   else{ /* use template pane size */
  103.  
  104.      paneelement->panesize.x = panestate.openblock.screenrect.max.x -
  105.                                panestate.openblock.screenrect.min.x;
  106.                                
  107.      paneelement->panesize.y = panestate.openblock.screenrect.max.y -
  108.                                panestate.openblock.screenrect.min.y;
  109.   }
  110.  
  111.  /*
  112.   * add list element to end of list
  113.   */
  114.   LinkList_AddToTail(&(mainelement->paneanchor), &(paneelement->header));
  115.  
  116.  /*
  117.   * install open window event handler for pane window if it is !ArtWorks style
  118.   */
  119.   if(!paneelement->paneflags.data.fixed)
  120.      Event_Claim(event_OPEN, panewindow, event_ANY, PaneOpenEventHandler, paneelement);
  121.  
  122.   return(TRUE);
  123. }
  124.